<?php
defined('IN_ADMIN') or exit('No permission resources.');
$show_validator = $show_scroll = $show_dialog = 1;
include $this->admin_tpl('header','admin');
?>
<script type="text/javascript">
<!--
$(function(){
	$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
	$("#name").formValidator({onshow:"<?php echo L("input").L('variable_name')?>",onfocus:"<?php echo L("input").L('variable_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('variable_name')?>"});
})
//-->
</script>
<div class="pad-lr-10">
  <form action="?m=variable&c=manage&a=edit&id=<?php echo $id;?>" method="post" id="myform">
    <fieldset>
	<legend><?php echo L('variable_info')?></legend>
	<table width="100%"  class="table_form">
  <tr>
    <th width="120"><?php echo L('variable_name')?>：</th>
    <td class="y-bg"><input type="text" id="name" class="input-text" name="info[name]" value="<?php echo $info['name']?>" size="30" /></td>
  </tr>
  <tr>
    <th><?php echo L('variable_desc')?>：</th>
    <td class="y-bg">
    	<textarea rows="4" cols="29" name="info[description]" id="description"><?php echo $info['description']?></textarea>
    </td>
  </tr>
    <tr>
      <th><?php echo L('variable_value')?>：</th>
      <td class="y-bg">
		<textarea rows="4" cols="29" name="info[value]" id="value"><?php echo $info['value']?></textarea>
      </td>
    </tr>
    <?php if(strpos($info['value'],"_")){$color_flag=explode('_', $info['value'])[1];}?>
    <tr>
    	<th><?php echo L('variable_color')?>：</th>
    	<td class="y-bg">
			<?php echo form::radio($this->color,$color_flag?$color_flag:0,'name="variable_color" class="color_select"');?>
     	</td>
    </tr>
    <tr>
    	<th><?php echo L('variable_view')?>：</th>
    	<td id="color_view" style="background: <?php echo $color_flag?>"></td>
    </tr>
</table>
</fieldset>
    <div class="bk15"></div>
    <input type="submit" class="dialog" id="dosubmit" name="dosubmit" value="<?php echo L('submit');?>" />
  </form>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$(".color_select").click(function(){
		var color = $(this).val();
		var variable_value = $("#value").val();
		if(variable_value.length>0){
			if(variable_value.indexOf('_')>0){
				var s = variable_value;
				var s_value=""
				s_value = s.substring(0,s.length-8)+'_'+color;
			} else {
				var s = variable_value;
				var s_value="";
				s_value = s+'_'+color;
			}
			$("#value").val(s_value);
		}
		$("#color_view").css("background",color);
	});
});
</script>
</body>
</html>
